import { BasicLayout, UserLayout } from '@/layouts';
import { RouteView } from '@hangar/pro-layout';
import { workplace, system } from '@/core/icons';
// import { demosRouter } from '@/config/demos-router.config';
/*
注意：
多标签页请尽量避免使用三级路由，多标签页存在问题
*/
export const defaultPage = '/workplace';
export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: {
      title: 'menu.home'
    },
    redirect: defaultPage, // 首页跳转地址
    children: [
      {
        path: '/workplace',
        name: 'Workplace',
        component: () => import('@/views/workplace/Workplace'),
        meta: {
          title: 'menu.workplace',
          icon: workplace
        }
      },
      // 其他路由请在这里添加
      // ...
      {
        path: '/system',
        name: 'system',
        component: RouteView,
        redirect: '/system/organizations',
        meta: {
          title: 'menu.system',
          icon: system,
          permission: ['system:organizations','system:users','system:roles','system:advertisements','system:messages','system:userMessages',],
        },
        children: [
          // {
          //   path: '/system/organization',
          //   name: 'organization',
          //   component: () => import('@/views/system/organization'),
          //   meta: {
          //     title: '组织机构管理',
          //     permission: ['system:organizations'],
          //     icon: workplace
          //   }
          // },
          {
            path: '/systemManage/organizationManage',
            name: 'organizationManage',
            component: () => import('@/views/systemManage/organizationManage'),
            meta: {
              title: '组织机构管理',
              permission: ['system:organizations'],
              icon: workplace
            }
          },
          // {
          //   path: '/system/user',
          //   name: 'user',
          //   component: () => import('@/views/system/user'),
          //   meta: {
          //     title: '用户管理',
          //     permission: ['system:users'],
          //     icon: workplace
          //   }
          // },
          {
            path: '/systemManage/userManage',
            name: 'userManage',
            component: () => import('@/views/systemManage/userManage'),
            meta: {
              title: '用户管理',
              permission: ['system:users'],
              icon: workplace
            }
          },
          // {
          //   path: '/system/role',
          //   name: 'role',
          //   component: () => import('@/views/system/role'),
          //   meta: {
          //     title: '角色管理',
          //     permission: ['system:roles'],
          //     icon: workplace
          //   }
          // },
          {
            path: '/systemManage/roleManage',
            name: 'roleManage',
            component: () => import('@/views/systemManage/roleManage'),
            meta: {
              title: '角色管理',
              permission: ['system:roles'],
              icon: workplace
            }
          },
          {
            path: '/systemManage/cardManage',
            name: 'cardManage',
            component: () => import('@/views/systemManage/cardManage'),
            meta: {
              title: '卡管理',
              permission: ['system:cardManage'],
              icon: workplace
            }
          },
          {
            path: '/systemManage/openScreenAdvertising',
            name: 'openScreenAdvertising',
            component: () => import('@/views/systemManage/openScreenAdvertising'),
            meta: {
              title: '开屏广告',
              permission: ['system:advertisements'],
              icon: workplace
            }
          },
          {
            path: '/systemManage/messageManagement',
            name: 'messageManagement',
            component: () => import('@/views/systemManage/messageManagement'),
            meta: {
              title: '消息管理',
              permission: ['system:messages'],
              icon: workplace
            }
          },
          {
            path: '/systemManage/myMessage',
            name: 'myMessage',
            component: () => import('@/views/systemManage/myMessage'),
            meta: {
              title: '我的消息',
              permission: ['system:userMessages'],
              icon: workplace
            }
          }
          // ,
          // {
          //   path: '/systemManage/demo',
          //   name: 'dome',
          //   component: () => import('@/views/systemManage/demo'),
          //   meta: {
          //     title: '演示',
          //     permission: ['system:roles'],
          //     icon: workplace
          //   }
          // }
        ]
      },
      {
        path: '/operationAndMaintenance',
        name: 'operationAndMaintenance',
        component: RouteView,
        meta: {
          title: 'menu.operationAndMaintenance',
          icon: system,
          permission: ['maintain:networks','maintain:package','maintain:cabinetTypes','maintain:cabinetModels','maintain:cabinets','maintain:chargingUsers','maintain:organizationAdditionalUsers'],
        },
        children: [
          // {
          //   path: '/operationAndMaintenance/jurisdictionManage',
          //   name: 'jurisdictionManage',
          //   component: () => import('@/views/operationAndMaintenance/jurisdictionManage'),
          //   meta: {
          //     title: '区划管理',
          //     permission: ['maintain:areas'],
          //     icon: workplace
          //   }
          // },
          // {
          //   path: '/operationAndMaintenance/userTemplate',
          //   name: 'userTemplate',
          //   component: () => import('@/views/operationAndMaintenance/userTemplate'),
          //   meta: {
          //     title: '安全模板',
          //     permission: ['maintain:cabinetSecurities'],
          //     icon: workplace
          //   }
          // },
          {
            path: '/operationAndMaintenance/businessOutlets',
            name: 'businessOutlets',
            component: () => import('@/views/operationAndMaintenance/businessOutlets'),
            meta: {
              title: '场站网点',
              permission: ['maintain:networks'],
              icon: workplace
            }
          },
          {
            path: '/operationAndMaintenance/package',
            name: 'package',
            component: () => import('@/views/operationAndMaintenance/package'),
            meta: {
              title: '充电套餐包',
              permission: ['maintain:package'],
              icon: workplace
            }
          },
          {
            path: '/operationAndMaintenance/equipmentType',
            name: 'equipmentType',
            component: () => import('@/views/operationAndMaintenance/equipmentType'),
            meta: {
              title: '设备类型',
              permission: ['maintain:cabinetTypes'],
              icon: workplace
            }
          },
          {
            path: '/operationAndMaintenance/equipmentInformation',
            name: 'equipmentInformation',
            component: () => import('@/views/operationAndMaintenance/equipmentInformation'),
            meta: {
              title: '型号信息',
              permission: ['maintain:cabinetModels'],
              icon: workplace
            }
          },
          {
            path: '/operationAndMaintenance/chargingCabinet',
            name: 'chargingCabinet',
            component: () => import('@/views/operationAndMaintenance/chargingCabinet'),
            meta: {
              title: '充电柜',
              permission: ['maintain:cabinets'],
              icon: workplace
            }
          },
          {
            path: '/operationAndMaintenance/chargingUser',
            name: 'chargingUser',
            component: () => import('@/views/operationAndMaintenance/chargingUser'),
            meta: {
              title: '充电用户',
              permission: ['maintain:chargingUsers'],
              icon: workplace
            }
          },
          {
            path: '/operationAndMaintenance/whiteListManage',
            name: 'whiteListManage',
            component: () => import('@/views/operationAndMaintenance/whiteListManage'),
            meta: {
              title: '白名单管理',
              permission: ['maintain:organizationAdditionalUsers'],
              icon: workplace
            }
          },
          // {
          //   path: '/operationAndMaintenance/voiceDisablePeriod',
          //   name: 'voiceDisablePeriod',
          //   component: () => import('@/views/operationAndMaintenance/voiceDisablePeriod'),
          //   meta: {
          //     title: '语音播放',
          //     permission: ['maintain:disableVoiceTimes'],
          //     icon: workplace
          //   }
          // }
        ]
      },
      {
        path: '/postageManage',
        name: 'postageManage',
        component: RouteView,
        meta: {
          title: 'menu.postageManage',
          icon: system,
          permission: ['charges:charges'],
        },
        children: [
          {
            path: '/postageManage/postageSettings',
            name: 'postageSettings',
            component: () => import('@/views/postageManage/postageSettings'),
            meta: {
              title: '资费设置',
              permission: ['charges:charges'],
              icon: workplace
            }
          }
        ]
      },
      {
        path: '/equipmentControl',
        name: 'equipmentControl',
        component: RouteView,
        meta: {
          title: 'menu.equipmentControl',
          icon: system,
          permission: ['control:cabinets'],
        },
        children: [
          {
            path: '/equipmentControl/parameterSending',
            name: 'parameterSending',
            component: () => import('@/views/equipmentControl/parameterSending'),
            meta: {
              title: '参数下发',
              permission: ['control:cabinets'],
              icon: workplace
            }
          },
          // {
          //   path: '/equipmentControl/equipmentUpgrade',
          //   name: 'equipmentUpgrade',
          //   component: () => import('@/views/equipmentControl/equipmentUpgrade'),
          //   meta: {
          //     title: '设备升级',
          //     permission: ['control:upgrade'],
          //     icon: workplace
          //   }
          // }
        ]
      },
      {
        path: '/businessSystem',
        name: 'businessSystem',
        component: RouteView,
        meta: {
          title: 'menu.businessSystem',
          icon: system,
          permission: ['business'],
        },
        children: [
          {
            path: '/businessSystem/chargingInformation',
            name: 'chargingInformation',
            component: () => import('@/views/businessSystem/chargingInformation'),
            meta: {
              title: '充电信息',
              permission: ['business:organizationChargings'],
              icon: workplace
            }
          },
          {
            path: '/businessSystem/archiveOrder',
            name: 'archiveOrder',
            component: () => import('@/views/businessSystem/archiveOrder'),
            meta: {
              title: '归档订单',
              permission: ['business:organizationArchiveOrder'],
              icon: workplace
            }
          }
        ]
      },
      {
        path: '/equipmentMonitoring',
        name: 'equipmentMonitoring',
        component: RouteView,
        meta: {
          title: 'menu.equipmentMonitoring',
          icon: system,
          permission: ['monitor:cabinets','monitor:cabinetGatewayLogs','monitor:cabinetBinFaults'],
        },
        children: [
          {
            path: '/equipmentMonitoring/runningState',
            name: 'runningState',
            component: () => import('@/views/equipmentMonitoring/runningState'),
            meta: {
              title: '设备运行状况',
              permission: ['monitor:cabinets'],
              icon: workplace
            }
          },
          {
            path: '/equipmentMonitoring/gatewayLogs',
            name: 'gatewayLogs',
            component: () => import('@/views/equipmentMonitoring/gatewayLogs'),
            meta: {
              title: '报文日志记录',
              permission: ['monitor:cabinetGatewayLogs'],
              icon: workplace
            }
          },
          {
            path: '/equipmentMonitoring/alarmInformation',
            name: 'alarmInformation',
            component: () => import('@/views/equipmentMonitoring/alarmInformation'),
            meta: {
              title: '现有设备告警',
              permission: ['monitor:cabinetBinFaults'],
              icon: workplace
            }
          },
          {
            path: '/equipmentMonitoring/historyAlarmInformation',
            name: 'historyAlarmInformation',
            component: () => import('@/views/equipmentMonitoring/historyAlarmInformation'),
            meta: {
              title: '历史设备事件及告警',
              permission: ['monitor:cabinetBinHistoryFaults'],
              icon: workplace
            }
          }
        ]
      },
      // demosRouter
      // 统计类
      {
        path: '/statistics',
        name: 'statistics',
        component: RouteView,
        meta: {
          title: 'menu.statistics',
          icon: system,
          permission: ['statistic'],
        },
        children: [
          {
            path: '/statistics/runState',
            name: 'runState',
            component: () => import('@/views/statistics/runState'),
            meta: {
              title: '运营状态统计',
              permission: ['statistic:operationStatus'],
              icon: workplace
            }
          },
          {
            path: '/statistics/warnCategory',
            name: 'warnCategory',
            component: () => import('@/views/statistics/warnCategory'),
            meta: {
              title: '告警分类统计',
              permission: ['statistic:alarmClassification'],
              icon: workplace
            }
          },
          {
            path: '/statistics/orgElectricStatic',
            name: 'orgElectricStatic',
            component: () => import('@/views/statistics/orgElectricStatic'),
            meta: {
              title: '组织电量统计',
              permission: ['statistic:electricOrganization'],
              icon: workplace
            }
          },
          {
            path: '/statistics/networkElectric',
            name: 'networkElectric',
            component: () => import('@/views/statistics/networkElectric'),
            meta: {
              title: '场站电量统计',
              permission: ['statistic:electricNetwork'],
              icon: workplace
            }
          },
          {
            path: '/statistics/cabintElectric',
            name: 'cabintElectric',
            component: () => import('@/views/statistics/cabintElectric'),
            meta: {
              title: '充电柜电量统计',
              permission: ['statistic:electricCabinet'],
              icon: workplace
            }
          },
        ],
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
];

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import('@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import('@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import('@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/403',
    component: () => import('@/views/exception/403')
  },
  {
    path: '/404',
    component: () => import('@/views/exception/404')
  },
  {
    path: '/500',
    component: () => import('@/views/exception/500')
  }
];
